﻿@model CodeStash.Models.Snippet.EditSnippetViewModel
@using CodeStash.ExtensionsMethods
<div id="AjaxEditContents">
    @using (Html.BeginForm("Edit", "CodeSnippet", FormMethod.Post, new { id = "EditForm" }))
    {

        @Html.AntiForgeryToken("Edit")
        
        <h2>
            Edit Code Snippet : @Model.CodeSnippetId</h2>
        <p>
            Please fill in the details below, and when ready click the "Edit" button at the
            bottom of the page</p>


        <input id="successfulEdit" type="hidden" value="@ViewData["successfulEdit"]" />
        <input id="editedSnippetId" type="hidden" value="@ViewData["editedSnippetId"]" />
      
        @Html.HiddenFor((x) => x.CodeSnippetId)
        
        <div class="headedPanel">
            <strong>Title</strong>
            <div>
                @Html.TextBoxFor((x) => x.Title, new { @maxlength = "50" })
                &nbsp;
                @Html.ValidationMessageFor((x) => x.Title)
            </div>
            <br />
            <strong>Description</strong>
            <div>
                @Html.TextBoxFor((x) => x.Description, new { @maxlength = "200" })
                &nbsp;
                @Html.ValidationMessageFor((x) => x.Description)
            </div>
            <br />
            <strong>Category</strong>
            <div>
                Search for existing category
                <br />
                <input id="SearchCategoryText" type="text" />
                <input id="SearchForExistingCategories" type="button" value="Search" />
                <span class="clear"></span>
                <br />
                <select id="FoundCategories" style="display: none; margin-top: 5px; margin-bottom: 5px"
                    class="selectBox">
                </select>
                <br />
                Or fill in new category
                <br />
                @Html.TextBoxFor((x) => x.NewCodeCategoryName, new { @maxlength = "255" })
                &nbsp;
                @Html.ValidationMessageFor((x) => x.NewCodeCategoryName)
            </div>
            <br />
            <strong>Grouping</strong>
            <div>
                Search for existing grouping
                <br />
                <input id="SearchGroupingText" type="text" />
                <input id="SearchForExistingGrouping" type="button" value="Search" />
                <span class="clear"></span>
                <br />
                <select id="FoundGrouping" style="display: none; margin-top: 5px; margin-bottom: 5px"
                    class="selectBox">
                </select>
                <br />
                Or fill in new grouping
                <br />
                @Html.TextBoxFor((x) => x.NewGroupingName, new { @maxlength = "50" })
                &nbsp;
                @Html.ValidationMessageFor((x) => x.NewGroupingName)
            </div>
            <br />
            <strong>Language</strong>
            <div>
                @Html.ComboFor(x => x.LanguageId, x => x.LanguageList, x => x.LanguageId, x => x.Language1,
                    new Dictionary<string, object> { 
                        { "style", "width:400px"}, 
                        { "class", "selectBox"  }})
                &nbsp;
                @Html.ValidationMessageFor((x) => x.LanguageId)
            </div>
            <br />
            <strong>Code Snippet Visibility</strong>
            <div>
                @Html.ComboFor(x => x.Visibility, x => x.VisibilityList, x => x.Id, x => x.VisibilityDescription,
                    new Dictionary<string, object> { 
                        { "style", "width:400px"}, 
                        { "class", "selectBox"  }})
                &nbsp;
                @Html.ValidationMessageFor((x) => x.Visibility)
            </div>
            <div>
                <strong>Tags</strong>&nbsp; &nbsp; &nbsp;Enter tags seperated by ";"
                <div>
                    @Html.TextBoxFor((x) => x.Tags)
                    &nbsp;
                    @Html.ValidationMessageFor((x) => x.Tags)
                </div>
            </div>
            <br />
            <strong>Actual Code</strong>
            <div>
                @Html.TextAreaFor((x) => x.ActualCode, new { id = "editTextFieldsCode" })
                &nbsp;
                <div id="actualCodeError">@Html.ValidationMessageFor((x) => x.ActualCode)</div>
            </div>
            <p>
                <br />
                <input id="EditSubmit" type="submit" value="Save" />
                <br />
            </p>
        </div>
    }
</div>
